package com.t2c.tibetantochinese.fivehundred;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.t2c.tibetantochinese.R;
import com.t2c.tibetantochinese.moudle.FiveHundredList;
import com.t2c.tibetantochinese.realmModel.Category;

import java.util.List;

import io.realm.RealmResults;

/**
 * Created by zoulu on 16/6/26.
 * adapter
 */
public class FiveHundredAdapter extends BaseAdapter{
    private Context mContext;
    private RealmResults<Category> data;

    public FiveHundredAdapter(Context context, RealmResults<Category> list){
        this.mContext = context;
        this.data = list;
    }
    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Holder holder;
        if(convertView == null ) {
            LayoutInflater inflater = LayoutInflater.from(mContext);
            convertView = inflater.inflate(R.layout.fivehundred_item, null);
            holder = new Holder();
            holder.name = (TextView)convertView.findViewById(R.id.name);
            holder.iv_sound = (ImageView) convertView.findViewById(R.id.iv_sound);
            convertView.setTag(holder);
        } else {
            holder = (Holder) convertView.getTag();
        }
        holder.name.setText(data.get(position).getName());

        return convertView;
    }

    private class Holder{
        TextView name;
        ImageView iv_sound;
    }

}
